Imports System.Data.SqlClient


Public Class DnnSecuritySQL
    Public Shared Function DirectQuery (ByVal query As String) As DataTable
        Dim ds As DataSet = New DataSet()
        Dim dt As DataTable = Nothing
        Dim conn As SqlConnection = Nothing
        Dim connStr As String = ConfigurationManager.AppSettings ("SiteSqlServer")

        Try
            conn = New SqlConnection (connStr)

            Dim command As SqlCommand = New SqlCommand (query, conn)
            command.CommandType = CommandType.Text

            Dim adapter As New SqlDataAdapter (command)
            conn.Open()
            adapter.Fill (ds)
            dt = ds.Tables (0)
            'log something
        Catch e As Exception
        Finally
            Try
                conn.Close()
            Catch
            End Try

            Try
                ds.Dispose()
            Catch
            End Try
        End Try

        Return dt
    End Function
End Class